//
//  PublishStore ViewController.m
//  RENTVISITOR
//
//  Created by wonder on 2017/9/28.
//  Copyright © 2017年 UNN. All rights reserved.
//

#import "PublishStore ViewController.h"
#import "RentVieitor.h"
#import "SelectViewController.h"
#import "AssortSelectViewController.h"
#import "PublishDetailViewController.h"
#import "UploadFileViewController.h"
#import "PublishImgViewController.h"

@interface PublishStore_ViewController ()<UIScrollViewDelegate,UITextFieldDelegate>

@end

@implementation PublishStore_ViewController{
    
    UIScrollView *scrollView;
    
    NSString *detailStr;//详情描述
    NSString *deposit_method;//押金方式
    NSString *rent_method;//付租方式
    NSArray *deposit_methodArray;
    NSArray *rentArray;
    NSString *bedroom;//卧室数量
    NSString *livingroom;//客厅数量
    NSString *washroom;//厕所数量
    NSString *subsidiary;//配套
    NSString *characteristic;//特色
    NSString *fileImg;
    NSString *rentImg;
    UIView *markView;
    
    
    
    
}

- (void)viewWillAppear:(BOOL)animated {
    
    // 自定义导航栏左侧按钮
    UIButton * leftBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    leftBtn.frame = CGRectMake(-5, 0, 10, 15);
    [leftBtn setBackgroundImage:[UIImage imageNamed:@""] forState:UIControlStateNormal];
    [leftBtn addTarget:self action:@selector(backAction) forControlEvents:UIControlEventTouchUpInside];
    UIBarButtonItem * leftItem = [[UIBarButtonItem alloc] initWithCustomView:leftBtn];
    self.navigationItem.leftBarButtonItem = leftItem;
    self.navigationController.tabBarController.tabBar.hidden = YES;
    self.navigationController.navigationBar.hidden = YES;
    
}


- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.title = @"发布商铺信息";
    self.view.backgroundColor = BackgroundColor;
    [self creatLeftView];
    [self creatView];
    [self creatAlertView];
    
}

- (void)creatAlertView {
    
    
    markView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, KWidth, KHeight)];
    markView.backgroundColor = [UIColor colorWithWhite:0.5 alpha:0.5];
    
    markView.userInteractionEnabled = YES;
    //    [markView becomeFirstResponder];
    [self.view insertSubview:markView belowSubview:self.view];
    
    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
    NSString *isAgent = [defaults objectForKey:@"status"];
    if ([isAgent isEqualToString:@"2"]) {
        markView.hidden = YES;
    }else {
        markView.hidden = NO;
    }
    
    
    UIView *alertView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, KWidth-100,50+75+60)];
    alertView.backgroundColor = [UIColor whiteColor];
    alertView.layer.masksToBounds = YES;
    alertView.layer.cornerRadius = 2;
    alertView.center = markView.center;
    
    UILabel *selectLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 20, KWidth-140, 15)];
    selectLabel.text = @"您还不是经纪人";
    selectLabel.font = [UIFont boldSystemFontOfSize:15];
    selectLabel.textAlignment = NSTextAlignmentCenter;
    selectLabel.textColor = [Utils colorConvertFromString:@"#101010"];
    [alertView addSubview:selectLabel];
    
    NSArray *textArray = @[@"* 请提供与个人身份证对应的房产证明",@"* 若改房屋非您本人所有请一并上传",@"   独家委托租赁协议",@"* 您也可以直接申请为经纪人"];
    CGFloat hight = 12;
    CGFloat margin = 12.5;
    CGFloat width = KWidth-154;
    for (int i=0; i<textArray.count; i++) {
        
        
        if (i==2) {
            margin = 8;
        }
        UILabel *selectLabel = [[UILabel alloc] initWithFrame:CGRectMake(27, 55+(margin+hight)*i, width, 15)];
        selectLabel.text = textArray[i];
        selectLabel.font = [UIFont systemFontOfSize:12];
        selectLabel.textAlignment = NSTextAlignmentLeft;
        selectLabel.textColor = [Utils colorConvertFromString:@"#101010"];
        [alertView addSubview:selectLabel];
        
        
    }
    
    CALayer *lineLayer2 = [CALayer layer];
    lineLayer2.backgroundColor = [[UIColor colorWithRed:217/255.0 green:217/255.0 blue:217/255.0 alpha:1] CGColor];
    lineLayer2.frame = CGRectMake(0,50+75+20,KWidth-100, 1);
    [alertView.layer addSublayer:lineLayer2];
    
    CALayer *mlineLayer2 = [CALayer layer];
    mlineLayer2.backgroundColor = [[UIColor colorWithRed:217/255.0 green:217/255.0 blue:217/255.0 alpha:1] CGColor];
    mlineLayer2.frame = CGRectMake((KWidth-100)/2,50+75+20,1,40);
    [alertView.layer addSublayer:mlineLayer2];
    
    UIButton *sureButton = [UIButton buttonWithType:UIButtonTypeSystem];
    sureButton.frame = CGRectMake(0, 50+75+20, (KWidth-100-1)/2, 40);
    [sureButton addTarget:self action:@selector(applianAction) forControlEvents:UIControlEventTouchUpInside];
    [sureButton setTitle:@"申请经纪人" forState:UIControlStateNormal];
    
    [alertView addSubview:sureButton];
    
    UIButton *canceButton = [UIButton buttonWithType:UIButtonTypeSystem];
    canceButton.frame = CGRectMake((KWidth-100-1)/2, 50+75+20, (KWidth-100-1)/2, 40);
    [canceButton setTitle:@"继续提交" forState:UIControlStateNormal];
    [canceButton addTarget:self action:@selector(continueAction) forControlEvents:UIControlEventTouchUpInside];
    [alertView addSubview:canceButton];
    
    [markView addSubview:alertView];
}

- (void)creatLeftView {
    
    UIView *headView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, KWidth, 120)];
    headView.backgroundColor = [Utils colorConvertFromString:@"#1fae0c"];
    [self.view addSubview:headView];
    
    UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(100, 20, KWidth-200, 40)];
    label.text = @"发布租房信息";
    label.textAlignment = NSTextAlignmentCenter;
    label.font = [UIFont systemFontOfSize:17];
    label.textColor = [UIColor whiteColor];
    [headView addSubview:label];
    // 自定义导航栏左侧按钮
    UIButton * leftBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    leftBtn.frame = CGRectMake(15, 20+12, 100,30);
    [leftBtn setImageEdgeInsets:UIEdgeInsetsMake(0, 0, 10, 90)];
    [leftBtn setImage:[UIImage imageNamed:@"箭头左-left"] forState:UIControlStateHighlighted];
    [leftBtn setImage:[UIImage imageNamed:@"箭头左-left"] forState:UIControlStateNormal];
    [leftBtn addTarget:self action:@selector(backAction) forControlEvents:UIControlEventTouchUpInside];
    [headView addSubview:leftBtn];
    
    // 自定义导航栏左侧按钮
    UIButton * rightBtn = [UIButton buttonWithType:UIButtonTypeSystem];
    rightBtn.frame = CGRectMake(KWidth-65, 20+10, 50, 20);
    [rightBtn setTitle:@"下一步" forState:UIControlStateNormal];
    [rightBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [rightBtn addTarget:self action:@selector(nextAction) forControlEvents:UIControlEventTouchUpInside];
    [headView addSubview:rightBtn];
    
    UIImageView *imgview = [[UIImageView alloc] initWithFrame:CGRectMake(0, 64, KWidth, KWidth*136/966)];
    imgview.image = [UIImage imageNamed:@"publish2"];
    [headView addSubview:imgview];
    
    UILabel *firstLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 140, KWidth, 20)];
    firstLabel.text = @"第二步  填写信息";
    firstLabel.textAlignment = NSTextAlignmentCenter;
    firstLabel.font = [UIFont systemFontOfSize:17];
    firstLabel.textColor = [Utils colorConvertFromString:@"#101010"];
    [self.view addSubview:firstLabel];
    
    UILabel *secondLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 170, KWidth, 13)];
    secondLabel.text = @"请填写下相关商铺信息";
    secondLabel.textAlignment = NSTextAlignmentCenter;
    secondLabel.font = [UIFont systemFontOfSize:13];
    secondLabel.textColor = [Utils colorConvertFromString:@"#666666"];
    [self.view addSubview:secondLabel];
}

- (void)creatView {
    
    scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 200, KWidth, KHeight-200)];
    scrollView.backgroundColor = BackgroundColor;
    scrollView.contentSize = CGSizeMake(KWidth, 610+271);
    scrollView.delegate = self;
    scrollView.showsVerticalScrollIndicator = NO;
    scrollView.showsHorizontalScrollIndicator = NO;
    [self.view addSubview:scrollView];
    
    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
    NSString *isAgent = [defaults objectForKey:@"status"];
    NSArray *titleArray = @[@"小区名",@"地址",@"类型",@"面积",@"楼层",@"总楼层",@"装修",@"租金",@"佣金",@"押租方式",@"付租方式",@"标题",@"详细描述",@"特色标签",@"房产证明",@"房屋租赁证明"];
    NSArray *placArray = @[@"小区名",@"请填写小区地址",@"点击选择类型",@"m²",@"请选择楼层",@"请填写总楼层",@"点击选择装修",@"请输入租金",@"请输入佣金",@"付租方式",@"押租方式",@"标题长度只是3个汉字,最多50个",@"",@"",@"上传图片",@"上传图片"];
    //选项视图
    CGFloat heigt = 50;
    for (int i=0; i<titleArray.count; i++) {
        
        UIView *selectView = [[UIView alloc] init];
        selectView.backgroundColor = [UIColor whiteColor];
        selectView.tag = 100+i;
        selectView.frame = CGRectMake(0,heigt*i , KWidth, heigt);
        [scrollView addSubview:selectView];
        
        
        UILabel *selectLabel = [[UILabel alloc] init];
        selectLabel.text = titleArray[i];
        selectLabel.font = [UIFont systemFontOfSize:15];
        selectLabel.textAlignment = NSTextAlignmentLeft;
        selectLabel.textColor = [Utils colorConvertFromString:@"#101010"];
        [selectView addSubview:selectLabel];
        
        CGSize size2 = [@"房屋户型" boundingRectWithSize:CGSizeMake(KWidth, 25) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:selectLabel.font} context:nil].size;
        
        if (i == 15) {
            
            size2 = [@"房屋租赁证明" boundingRectWithSize:CGSizeMake(KWidth, 25) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:selectLabel.font} context:nil].size;
        }
        
        if (i >= titleArray.count -2) {
            
            if ([isAgent isEqualToString:@"2"] == NO) {
                
                selectView.hidden = NO;
            }else {
                selectView.hidden = YES;
            }
            
        }
        
        selectLabel.frame = CGRectMake(20, 10, size2.width, 30);
        UITextField *textfile = [[UITextField alloc] initWithFrame:CGRectMake(size2.width+30, 10,KWidth-65-size2.width , 30)];
        textfile.tag = 200+i;
        textfile.delegate = self;
        textfile.placeholder = placArray[i];
        textfile.textColor = [Utils colorConvertFromString:@"#666666"];
        textfile.font = [UIFont systemFontOfSize:13];
        textfile.textAlignment = NSTextAlignmentRight;
        [selectView addSubview:textfile];
        
        if (i==2 || i==4 ||i==6 ||i==9 || i==10  || i==14 || i==13 || i==15 || i==12 ) {
            
            UIButton *selectButton = [UIButton buttonWithType:UIButtonTypeCustom];
            selectButton.frame = CGRectMake(KWidth-25, 20, 5, 10);
            [selectButton setBackgroundImage:[UIImage imageNamed:@"箭头-右"] forState:UIControlStateNormal];
            [selectView addSubview:selectButton];
        }
        
        
        
        //分割线
        CALayer *MlineLayer5 = [CALayer layer];
        MlineLayer5.backgroundColor = [[Utils colorConvertFromString:@"#cfcfcf"] CGColor];
        MlineLayer5.frame = CGRectMake(20 ,heigt-1, KWidth-40,1);
        if (i== 15) {
            MlineLayer5.hidden = YES;
        }
        [selectView.layer addSublayer:MlineLayer5];
    }
    
}

- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField {
    
    SelectViewController *selectVc = [[SelectViewController alloc] init];
    AssortSelectViewController *assVc = [[AssortSelectViewController alloc] init];
    PublishDetailViewController *detailVc = [[PublishDetailViewController alloc] init];
    //选择户型
    if (textField.tag == 202) {
        selectVc.data = @[@"购物中心",@"社区商业",@"综合体配套",@"其他"];
        selectVc.titleName = @"选择类型";
        [self.navigationController pushViewController:selectVc animated:YES];
        [selectVc returnTypeBlock:^(NSString *content) {
            
            textField.text = content;
            NSLog(@"%@",content);
        }];
        
        [selectVc returnIndexBlock:^(NSString *content) {
            
            
        }];
        return NO;
    }
    
    //选择楼层
    if (textField.tag == 204) {
        
        selectVc.data = @[@"低层",@"中层",@"高层",@"其他"];
        selectVc.titleName = @"选择楼层";
        [self.navigationController pushViewController:selectVc animated:YES];
        [selectVc returnTypeBlock:^(NSString *content) {
            
            textField.text = content;
            NSLog(@"%@",content);
        }];
        
        [selectVc returnIndexBlock:^(NSString *content) {
            
            
        }];
        return NO;
    }
    
    //选择装修
    if (textField.tag == 206) {
        selectVc.data = @[@"豪华装修",@"简单装修",@"无装修",@"遗留装修"];
        selectVc.titleName = @"选择装修";
        [self.navigationController pushViewController:selectVc animated:YES];
        [selectVc returnTypeBlock:^(NSString *content) {
            
            textField.text = content;
            NSLog(@"%@",content);
        }];
        return NO;
    }
    
    //选择押金方式
    if (textField.tag == 209) {
        selectVc.data = @[@"押一",@"押二",@"押三"];
        selectVc.titleName = @"押金方式";
        deposit_methodArray = @[@"1",@"2",@"3"];
        [self.navigationController pushViewController:selectVc animated:YES];
        [selectVc returnTypeBlock:^(NSString *content) {
            
            textField.text = content;
            NSLog(@"%@",content);
        }];
        
        [selectVc returnIndexBlock:^(NSString *content) {
            
            deposit_method = deposit_methodArray[[content integerValue]-1];
            NSLog(@"%@",content);
        }];
        return NO;
    }
    
    //选择租金方式
    if (textField.tag == 210) {
        selectVc.data = @[@"月度付",@"季度付",@"半年付",@"年付"];
        rentArray = @[@"1",@"3",@"6",@"12"];
        selectVc.titleName = @"付租方式";
        [self.navigationController pushViewController:selectVc animated:YES];
        [selectVc returnTypeBlock:^(NSString *content) {
            
            textField.text = content;
            NSLog(@"%@",content);
        }];
        
        [selectVc returnIndexBlock:^(NSString *content) {
            
            rent_method = rentArray[[content integerValue] -1];
            NSLog(@"%@",content);
        }];
        
        return NO;
    }
    
    //详细描述
    if (textField.tag == 212) {
        
        detailVc.titleName = @"详细描述";
        detailVc.detail = detailStr;
        [self.navigationController pushViewController:detailVc animated:YES];
        [detailVc returnDetailBlock:^(NSString *detail) {
            
            detailStr = detail;
            textField.text = @"已经填写(可修改)";
        }];
        return NO;
    }
    //选择特色标签
    if (textField.tag == 213) {
        
        assVc.data = @[@"沿街旺铺",@"繁华地段",@"专业市场",@"住宅底商",@"综合体配套",@"地铁口附近",@"独栋整层",@"小面积",@"知名商户入驻",@"可分隔办公室"];
        assVc.titleName = @"选择特色标签";
        [self.navigationController pushViewController:assVc animated:YES];
        [assVc returnAssortBlock:^(NSString *assort) {
            
            NSLog(@"%@",assort);
            characteristic = assort;
            textField.text = @"已选择(点击修改)";
        }];
        return NO;
    }
    
    if (textField.tag == 214) {
        
        UploadFileViewController *upVc = [[UploadFileViewController alloc] init];
        upVc.fileImg = rentImg;
        [self.navigationController pushViewController:upVc animated:YES];
        [upVc returnImgBlock:^(NSString *img) {
            
            rentImg = img;
            textField.text = @"已上传(可修改)";
        }];
        return NO;
    }
    
    if (textField.tag == 215) {
        
        UploadFileViewController *upVc = [[UploadFileViewController alloc] init];
        upVc.fileImg = fileImg;
        [self.navigationController pushViewController:upVc animated:YES];
        [upVc returnImgBlock:^(NSString *img) {
            
            fileImg = img;
            textField.text = @"已上传(可修改)";
        }];
        return NO;
    }
    
    return YES;
}

- (void)backAction {
    
    [self.navigationController popViewControllerAnimated:YES];
}

//下一步
- (void)nextAction {
    
    //名称community
    UIView *communityView = (UIView *)[scrollView viewWithTag:100];
    UITextField *communityfield = (UITextField *)[communityView viewWithTag:200];
    if (communityfield.text == nil || [communityfield.text isEqualToString:@""] ) {
        
        [APPDELEGATE showPro:@"请输入名称"];
        return;
    }
    
    
    //地址
    UIView *addressView = (UIView *)[scrollView viewWithTag:101];
    UITextField *addressfield = (UITextField *)[addressView viewWithTag:201];
    if (addressfield.text == nil || [addressfield.text isEqualToString:@""] ) {
        
        [APPDELEGATE showPro:@"请输入地址"];
        return;
    }
    
    //类型type
    UIView *typeView = (UIView *)[scrollView viewWithTag:102];
    UITextField *typefield = (UITextField *)[typeView viewWithTag:202];
    if (typefield.text == nil || [typefield.text isEqualToString:@""] ) {
        
        [APPDELEGATE showPro:@"请选择类型"];
        return;
    }
    
    //面积
    UIView *areaView = (UIView *)[scrollView viewWithTag:103];
    UITextField *areafield = (UITextField *)[areaView viewWithTag:203];
    if (areafield.text == nil || [areafield.text isEqualToString:@""] ) {
        
        [APPDELEGATE showPro:@"请输入房屋面积"];
        return;
    }
    
    //楼层
    UIView *floorView = (UIView *)[scrollView viewWithTag:104];
    UITextField *floorfield = (UITextField *)[floorView viewWithTag:204];
    if (floorfield.text == nil || [floorfield.text isEqualToString:@""] ) {
        
        [APPDELEGATE showPro:@"请选择楼层"];
        return;
    }
    
    //总楼层
    UIView *floorsView = (UIView *)[scrollView viewWithTag:105];
    UITextField *floorsfield = (UITextField *)[floorsView viewWithTag:205];
    if (floorsfield.text == nil || [floorsfield.text isEqualToString:@""] ) {
        
        [APPDELEGATE showPro:@"请输入总楼层"];
        return;
    }
    
    //decoration装修
    UIView *decorationView = (UIView *)[scrollView viewWithTag:106];
    UITextField *decorationfield = (UITextField *)[decorationView viewWithTag:206];
    if (decorationfield.text == nil || [decorationfield.text isEqualToString:@""] ) {
        
        [APPDELEGATE showPro:@"请输入房屋装修"];
        return;
    }
    
    
    //rent租金
    UIView *rentView = (UIView *)[scrollView viewWithTag:107];
    UITextField *rentfield = (UITextField *)[rentView viewWithTag:207];
    if (rentfield.text == nil || [rentfield.text isEqualToString:@""] ) {
        
        [APPDELEGATE showPro:@"请输入租金"];
        return;
    }
    
    //commission佣金
    UIView *commissionView = (UIView *)[scrollView viewWithTag:108];
    UITextField *commissionfield = (UITextField *)[commissionView viewWithTag:208];
    if (commissionfield.text == nil || [commissionfield.text isEqualToString:@""] ) {
        
        [APPDELEGATE showPro:@"请输入佣金"];
        return;
    }
    
    //deposit_method押金方式
    UIView *depositView = (UIView *)[scrollView viewWithTag:110];
    UITextField *depositfield = (UITextField *)[depositView viewWithTag:210];
    if (depositfield.text == nil || [depositfield.text isEqualToString:@""] ) {
        
        [APPDELEGATE showPro:@"请选择押金方式"];
        return;
    }
    
    //付租方式
    UIView *rentView2 = (UIView *)[scrollView viewWithTag:109];
    UITextField *rentfield2 = (UITextField *)[rentView2 viewWithTag:209];
    if (rentfield2.text == nil || [rentfield2.text isEqualToString:@""] ) {
        
        [APPDELEGATE showPro:@"请输入付租方式"];
        return;
    }
    
    //title
    UIView *titleView = (UIView *)[scrollView viewWithTag:111];
    UITextField *titlefield = (UITextField *)[titleView viewWithTag:211];
    if (titlefield.text == nil || [rentfield2.text isEqualToString:@""] ) {
        
        [APPDELEGATE showPro:@"请输入标题"];
        return;
    }
    
    //describe
    UIView *describeView = (UIView *)[scrollView viewWithTag:112];
    UITextField *describefield = (UITextField *)[describeView viewWithTag:212];
    if (describefield.text == nil || [describefield.text isEqualToString:@""] ) {
        
        [APPDELEGATE showPro:@"请输入详细信息"];
        return;
    }
    
    //characteristic
    UIView *characteristicView = (UIView *)[scrollView viewWithTag:113];
    UITextField *characteristicfield = (UITextField *)[characteristicView viewWithTag:213];
    if (characteristicfield.text == nil || [characteristicfield.text isEqualToString:@""] ) {
        
        [APPDELEGATE showPro:@"请选择特色标签"];
        return;
    }
    
    //判断是不是经纪人,需不需要传房产证明
    NSDictionary *dataDic = User_listsValue;
    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
    NSString *isAgent = [defaults objectForKey:@"status"];
    if ([isAgent isEqualToString:@"2"]) {
        
        if (fileImg == nil) {
            fileImg = @"";
        }
        
        if (rentImg == nil) {
            rentImg = @"";
        }
    }else {
        
        if (fileImg == nil || [fileImg isEqualToString:@""]) {
            
            [APPDELEGATE showPro:@"请上传房产证明"];
            return;
        }
        
        if (rentImg == nil || [rentImg isEqualToString:@""]) {
            
            [APPDELEGATE showPro:@"请上传租赁证明"];
            return;
        }
    }
    
    
    NSString *url = [NSString stringWithFormat:@"%@member/lease/shop",Main_Url];
    NSString *number = dataDic[@"number"];
    NSString *token = dataDic[@"token"];
    __weak typeof(self)WeakSelf = self;
    
    /*
     
     
     
     address
     type
     square
     floor
     total_floor
     decoration
     rent
     deposit_method
     rent_method
     title
     describe
     characteristic
     private_number
     photo_zhengming
     photo_xieyi
     
     
     */
    
    NSDictionary *param = @{
                            @"number":number,
                            @"token":token,
                            @"city":@"1",
                            @"district":@"1002",
                            @"region":@"10062",
                            @"community":communityfield.text,
                            @"commission":commissionfield.text,
                            @"address":addressfield.text,
                            @"type":typefield.text,
                            @"square":areafield.text,
                            @"floor":floorfield.text,
                            @"total_floor":floorsfield.text,
                            @"decoration":decorationfield.text,
                            @"rent":rentfield.text,
                            @"deposit_method":deposit_method,
                            @"rent_method":rent_method,
                            @"title":titlefield.text,
                            @"describe":detailStr,
                            @"characteristic":characteristic,
                            @"private_number":@"30",
                            @"photo_zhengming":fileImg,
                            @"photo_xieyi":rentImg,
                            };
    NSString *str = [ReturnSign returnSignWithDic:param];
    NSString *md5String = [NSString stringWithFormat:@"%@%@%@",str,APPKEY_URL,url];
    
    //32位小写
    
    //    NSString *nickname = [nameText.text stringByAddingPercentEscapesUsingEncoding:
    //                          NSUTF8StringEncoding];
    
    md5String = [LCMD5Tool MD5ForLower32Bate:md5String];
    NSMutableDictionary * param2 = [NSMutableDictionary dictionaryWithDictionary:param];
    [param2 setObject:md5String forKey:@"sign"];
    
    PublishImgViewController *publishVc = [[PublishImgViewController alloc] init];
    [AFHttpTool requestWihtUrl:url params:param2 success:^(id response) {
        
        
        if ([response[@"code"] isEqualToString:@"10000"]) {
            
            NSString *sn = response[@"sn"];
            publishVc.sn = sn;
            [WeakSelf.navigationController pushViewController:publishVc animated:YES];
            
            
        }else {
            
            [APPDELEGATE showPro:@"网络错误,请联系客服"];
        }
        
    } failure:^(NSError *err) {
        
        
    }];
}

- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView {
    
    [self.view endEditing:YES];
}

- (void)textFieldDidEndEditing:(UITextField *)textField {
    
    if (textField.tag == 3) {
        
        textField.text = [NSString stringWithFormat:@"%@ m²",textField.text];
    }
    
}

- (void)applianAction {
    
    [self.navigationController popToRootViewControllerAnimated:YES];
}

- (void)continueAction {
    
    markView.hidden = YES;
}

@end
